//
// api.js
// vue3-element-admin
//
// Created by 区区电脑 on 2023/04/11.
//


import request from "@/request"


// 分页
export function GetExportFilePageList(params = {}, data = {}) {
    return request({url: '/api/ExportFile/GetExportFilePageList', method: 'POST', params, data})
}

// 列表
export function GetExportFileList(data = {}) {
    return request({url: '/api/ExportFile/GetExportFileList', method: 'POST', data})
}


// 删除
export function DeleteFile(params = {}) {
    return request({url: '/api/ExportFile/DeleteFile', method: 'DELETE', params})
}


// 下载
export function DownloadFile(params, fileName) {
    return request({url: "/api/ExportFile/DownloadFile", method: "post", params, responseBlob: true}).then(({data}) => {
        if (data) {
            const downloadUrl = URL.createObjectURL(data);
            const a = document.createElement("a");
            a.download = `${fileName}`;
            a.href = downloadUrl;
            document.body.appendChild(a);
            a.click();
            document.body.removeChild(a);
            window.URL.revokeObjectURL(downloadUrl);
            return {
                success: true,
            }
        } else {
            return {
                success: false,
            }
        }
    })
}

